<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<form action="">
  用户名：<input type="text" name="user"><br>
  密码：<input type="password" name="pwd"><br>
  <input type="submit">
</form>
<script>
  var oF = document.forms[0];
  oF.onsubmit = function () {
    oF.user.value = encodeURI(oF.user.value);
  };
</script>
</body>
</html>